import numpy as np
import pandas as pd
import scanpy as sc
sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.logging.print_versions()
results_file = './write/pbmc3k.h5ad' # the file that will store the analysis results
sc.settings.set_figure_params(dpi=80)
adata_1 = sc.read_10x_mtx(
'../data/pbmc3k_filtered_gene_bc_matrices/hg19/', # the directory with the `.mtx` file
var_names='gene_symbols', # use gene symbols for the variable names (variables-axis index)
cache=True) # write a cache file for faster subsequent reading
adata_2 = sc.read_10x_mtx(
'../data/pbmc3k_filtered_gene_bc_matrices/hg19/', # the directory with the `.mtx` file
var_names='gene_symbols', # use gene symbols for the variable names (variables-axis index)
cache=True) # write a cache file for faster subsequent reading
# import scanpy.api as sc
import mnnpy
corrected = mnnpy.mnn_correct(adata_1, adata_2)
corrected[0]
type(corrected)
len(corrected)
def conv_to_df(adata):
genes = adata.var.index.tolist()
barcodes = adata.obs.index.tolist()
mat = adata.X.transpose()
df = pd.DataFrame(data=mat, columns=barcodes, index=genes)
return df
df_1 = conv_to_df(corrected[0][0])
df_1.shape
df_2 = conv_to_df(corrected[0][1])
df_2.shape
df_1.equals(df_2)
df_1.sum().head()
df_2.sum().head()
from clustergrammer2 import net
net.load_df(df_1)
net.filter_N_top(inst_rc='row', N_top=100, rank_type='var')
net.normalize(axis='row', norm_type='zscore')
net.clip(-5, 5)
net.widget()
net.load_df(df_2)
net.filter_N_top(inst_rc='row', N_top=100, rank_type='var')
net.normalize(axis='row', norm_type='zscore')
net.clip(-5, 5)
net.widget()